package org.git.movie.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.git.movie.entity.NewsRecommend;
import org.git.movie.form.NewsRecommendForm;
import org.git.movie.mapper.ext.NewsRecommendExtMapper;
import org.git.movie.service.NewsRecommendService;
import org.git.movie.vo.NewsRecommendVo;
import org.git.movie.vo.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sqyc
 */
@Service
public class NewsRecommendServiceImpl implements NewsRecommendService {

    /**
     *
     */
    @Autowired
    private NewsRecommendExtMapper newsRecommendExtMapper;

    @Override
    public PageDto<NewsRecommendVo> findPage(NewsRecommendForm newsRecommend, int pageNo, int pageSize) {
        try{
            PageHelper.startPage(pageNo, pageSize, true);
            List<NewsRecommendVo> list = newsRecommendExtMapper.findPage(newsRecommend);
            //用PageInfo对结果进行包装
            PageInfo page = new PageInfo(list);
            //自定义转换方法
            return   PageDto.transPageInfo(page);

        }finally {
            PageHelper.clearPage();
        }
    }
}
